package clustering;
import java.util.*;
import preprocess.Text_Clean;
/*This is for clustering usage.*/
public class Article {
	private String pmid;
	private List<String> cold_bigrams;
	private List<String> cold_trigrams;
	private String tiab;
	public Article(){
		pmid = null;
		tiab = null;
		cold_bigrams = new ArrayList<String>();
		cold_trigrams = new ArrayList<String>();
	}
	public String getPmid() {
		return pmid;
	}
	public void setPmid(String pmid) {
		this.pmid = pmid;
	}
	
	public List<String> getCold_bigrams() {
		return cold_bigrams;
	}
	public void setCold_bigrams(List<String> locals, Text_Clean tc) {
		if(locals == null || locals.size()==0)
			return;
		for(String localtext: locals){
			if(localtext == null || localtext.length()==0 || localtext.equalsIgnoreCase("cold"))
				continue;
			String tokens[] = localtext.split(" ");
			if(tokens.length==1)
				continue;
			for(int i=0; i<tokens.length; i++){
				if(tokens[i].equalsIgnoreCase("cold")){
					if(i-1>=0 && !tc.Is_StopWord(tokens[i-1].toLowerCase()))
						cold_bigrams.add(tokens[i-1]+" "+tokens[i]);
					if(i+1<tokens.length && !tc.Is_StopWord(tokens[i+1].toLowerCase()))
						cold_bigrams.add(tokens[i]+" "+tokens[i+1]);
					break;
				}
			}
		}
		
	}
	public List<String> getCold_trigrams() {
		return cold_trigrams;
	}
	public void setCold_trigrams(List<String> locals, Text_Clean tc) {
		if(locals == null || locals.size()==0)
			return;
		for(String localtext: locals){
			if(localtext == null || localtext.length()==0 || localtext.equalsIgnoreCase("cold"))
				continue;
			String tokens[] = localtext.split(" ");
			if(tokens.length==1)
				continue;
			for(int i=0; i<tokens.length; i++){
				if(tokens[i].equalsIgnoreCase("cold")){
					if(i-2>=0 && !tc.Is_StopWord(tokens[i-1].toLowerCase()) && !tc.Is_StopWord(tokens[i-2].toLowerCase()))
						cold_trigrams.add(tokens[i-2]+" "+tokens[i-1]+" "+tokens[i]);
					if(i-1>=0 && i+1<tokens.length && !tc.Is_StopWord(tokens[i-1].toLowerCase()) && !tc.Is_StopWord(tokens[i+1].toLowerCase()))
						cold_trigrams.add(tokens[i-1]+" "+tokens[i]+" "+tokens[i+1]);
					if(i+2<tokens.length && !tc.Is_StopWord(tokens[i+1].toLowerCase()) && !tc.Is_StopWord(tokens[i+2].toLowerCase()))
						cold_trigrams.add(tokens[i]+" "+tokens[i+1]+" "+tokens[i+2]);
					break;
				}
			}
		
		}
		
	}
	public String getTiab() {
		return tiab;
	}
	public void setTiab(String tiab) {
		this.tiab = tiab;
	}
	
}
